package com.rt.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rt.common.annotation.Log;
import com.rt.common.core.controller.BaseController;
import com.rt.common.core.domain.AjaxResult;
import com.rt.common.enums.BusinessType;
import com.rt.system.domain.RtAssemblyConf;
import com.rt.system.service.IRtAssemblyConfService;
import com.rt.common.utils.poi.ExcelUtil;
import com.rt.common.core.page.TableDataInfo;

/**
 * 策略题型Controller
 * 
 * @author Yg
 * @date 2022-05-05
 */
@RestController
@RequestMapping("/system/assemblyconf")
public class RtAssemblyConfController extends BaseController
{
    @Autowired
    private IRtAssemblyConfService rtAssemblyConfService;

    /**
     * 查询策略题型列表
     */
    @PreAuthorize("@ss.hasPermi('system:assemblyconf:list')")
    @GetMapping("/list")
    public TableDataInfo list(RtAssemblyConf rtAssemblyConf)
    {
        startPage();
        List<RtAssemblyConf> list = rtAssemblyConfService.selectRtAssemblyConfList(rtAssemblyConf);
        return getDataTable(list);
    }

    /**
     * 导出策略题型列表
     */
    @PreAuthorize("@ss.hasPermi('system:assemblyconf:export')")
    @Log(title = "策略题型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RtAssemblyConf rtAssemblyConf)
    {
        List<RtAssemblyConf> list = rtAssemblyConfService.selectRtAssemblyConfList(rtAssemblyConf);
        ExcelUtil<RtAssemblyConf> util = new ExcelUtil<RtAssemblyConf>(RtAssemblyConf.class);
        return util.exportExcel(list, "策略题型数据");
    }

    /**
     * 获取策略题型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:assemblyconf:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rtAssemblyConfService.selectRtAssemblyConfById(id));
    }

    /**
     * 新增策略题型
     */
    @PreAuthorize("@ss.hasPermi('system:assemblyconf:add')")
    @Log(title = "策略题型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RtAssemblyConf rtAssemblyConf)
    {
        return toAjax(rtAssemblyConfService.insertRtAssemblyConf(rtAssemblyConf));
    }

    /**
     * 修改策略题型
     */
    @PreAuthorize("@ss.hasPermi('system:assemblyconf:edit')")
    @Log(title = "策略题型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RtAssemblyConf rtAssemblyConf)
    {
        return toAjax(rtAssemblyConfService.updateRtAssemblyConf(rtAssemblyConf));
    }

    /**
     * 删除策略题型
     */
    @PreAuthorize("@ss.hasPermi('system:assemblyconf:remove')")
    @Log(title = "策略题型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rtAssemblyConfService.deleteRtAssemblyConfByIds(ids));
    }
}
